#ifndef PACK_H
#define PACK_H

#include <QDebug>
#include <Qstring>
#include <QStringList>
using namespace std;

enum Type{
    TYPE_REGIST,
    TYPE_LOGIN,
    TYPE_CREATE_ROOM,
    TYPE_JOIN_ROOM
};

enum Err{
    SUCCESS,
    ERR_REGIST,
    ERR_LOGIN
};


class Pack
{
    int pack_size;
    unsigned char type;
    unsigned char err;
    char buf[4096];
    int count;

public:
    Pack();
    void setType(Type type){this->type = type;}
    void setErr(Err err){this->err = err;}
    Type getType(){return (Type)type;}
    Err getErr(){return (Err)err;}

    void append(const QString& val);
    QStringList getData();

    char* data(){return (char*)this;}
    int size(){return pack_size;}

    void clear();

};

#endif // PACK_H
